
package com.jg.myproject.presenter;

import com.jg.myproject.api.BaseObserver;
import com.jg.myproject.api.RetrofitFactory;
import com.jg.myproject.api.RxSchedulers;
import com.jg.myproject.api.bean.BaseEntity;
import com.jg.myproject.api.bean.CommonRequestBean;
import com.jg.myproject.api.bean.reponse.CommonReponseBean;
import com.jg.myproject.module.base.IBasePresenter;
import com.jg.myproject.pview.IProjectInfoView;

import io.reactivex.Observable;

public class ProjectInfoPresenter implements IBasePresenter<CommonRequestBean> {
    private IProjectInfoView mIProjectInfoView;
    public ProjectInfoPresenter(IProjectInfoView mIProjectInfoView){
        this.mIProjectInfoView = mIProjectInfoView;
    }
    @Override
    public void getData(CommonRequestBean commonRequestBean) {
        Observable<BaseEntity<CommonReponseBean>> observable = RetrofitFactory.getInstance().getProjectInfo(commonRequestBean);
        observable.compose(RxSchedulers.<BaseEntity<CommonReponseBean>>compose(
                mIProjectInfoView.<BaseEntity<CommonReponseBean>>bindToLife())).subscribe(new BaseObserver<CommonReponseBean>(mIProjectInfoView) {
            @Override
            protected void onHandleSuccess(BaseEntity<CommonReponseBean> bean) {
                mIProjectInfoView.getReponseBeans(bean);
            }
            @Override
            protected void onHandleError(BaseEntity<CommonReponseBean> t) {
            }
        });
    }
}
